local skel = fk.CreateSkill {
  name = "lb__yuqi",
  max_branches_use_time = {
    ["active"] = {
      [Player.HistoryRound] = 1
    },
    ["damage"] = {
      [Player.HistoryRound] = 1
    }
  }
}

Fk:loadTranslationTable {
  ["lb__yuqi"] = "欲欺",
  [":lb__yuqi"] = "每轮各限一次，出牌阶段或当你受到伤害后，你可以展示一张手牌并交给一名角色，然后其须将此牌当任意非装备牌使用，若转化前后牌名不同，其弃置所有手牌（至少一张）或受到2点伤害。",

  ["#lb__yuqi"] = "欲欺：你可以展示一张手牌并交给一名角色，然后其须将此牌当任意非装备牌使用",
  ["#lb__yuqi-dis"] = "欲欺：你可以弃置所有手牌，或取消后受到 %dest 对你造成的2点伤害",

  ["$lb__yuqi1"] = "我这有笔更好的交易，要来听听看吗？",
  ["$lb__yuqi2"] = "欲望会创造机会。",
}

local yuqi_use = function(player, target, cards)  --奇了，增加分支次数后用usedSkillTimes却还是0
  local room = player.room
  local card = Fk:getCardById(cards[1])
  player:showCards(card)
  room:obtainCard(target, card, true, fk.ReasonGive, player, skel.name)
  if target.dead then return end
  local use = room:askToUseVirtualCard(target, {
    name = Fk:getAllCardNames("btd"),
    subcards = cards,
    skill_name = skel.name,
    cancelable = false,
  })
  if use and use.card.name ~= card.name then
    if target:getHandcardNum() > 0 and room:askToSkillInvoke(target, { skill_name = skel.name, prompt = "#lb__yuqi-dis::" .. player.id }) then
      target:throwAllCards("h", "lb__yuqi")
    else
      room:damage {
        from = player,
        to = target,
        damage = 2,
        skillName = "lb__yuqi",
      }
    end
  end
end

skel:addEffect("active", {
  prompt = "#lb__yuqi",
  can_use = function(self, player)
    return player:getHandcardNum() > 0 and skel:withinBranchTimesLimit(player, "active", Player.HistoryRound)
  end,
  card_filter = function(self, player, to_select, selected)
    return #selected == 0 and Fk:currentRoom():getCardArea(to_select) == Player.Hand
  end,
  target_filter = function(self, player, to_select, selected, selected_cards)
    return to_select ~= player and #selected == 0
  end,
  feasible = function(self, player, selected, selected_cards, card)
    return #selected == 1 and #selected_cards == 1
  end,
  on_use = function(self, room, effect)
    local player = effect.from
    player:addSkillBranchUseHistory(skel.name, "active")
    yuqi_use(player, effect.tos[1], effect.cards)
  end,
})

skel:addEffect(fk.Damaged, {
  can_trigger = function(self, event, target, player, data)
    return player:hasSkill(skel.name) and target == player and not player:isKongcheng()
        and skel:withinBranchTimesLimit(player, "damage", Player.HistoryRound)
  end,
  on_cost = function(self, event, target, player, data)
    local s, ret = player.room:askToUseActiveSkill(player, {
      skill_name = skel.name,
      cancelable = true,
      prompt = "#lb__yuqi",
      skip = true,
    })
    if s and ret then
      event:setCostData(self, { tos = ret.targets, cards = ret.cards })
      return true
    end
  end,
  on_use = function(self, event, target, player, data)
    player:addSkillBranchUseHistory(skel.name, "damage")
    yuqi_use(player, event:getCostData(self).tos[1], event:getCostData(self).cards)
  end,
})

return skel
